package org.teamh.connection.json.handler;

import org.teamh.connection.json.event.JsonEventObject;
import org.teamh.game.Start;
import org.teamh.logic.datamodel.Creep;
import org.teamh.logic.datamodel.DatamodelManager;
import org.teamh.logic.datamodel.Tower;

public class FireOnHandler extends JsonMasterHandler{

	public FireOnHandler(Start start, DatamodelManager manager) {
		super(start, manager);
	}

	@Override
	public boolean handleMsg(JsonEventObject json) {
		if(json.getProperty() != null && json.getProperty().equals("fireOn")) {
			Tower tower = manager.getTower(json.getSource());
			Creep creep = manager.getCreep(json.getNewValue());
			
			if(tower != null) {
				tower.setFiresOn(creep);
			}
			
			return true;
		}
		
		return false;
	}
}
